﻿using System.Configuration;
using System.Data;
using System.Data.Common;
using System.Data.SqlClient;
using ZilLion.Service.Core.CRMUnities.Config;
using ZilLion.Service.Core.DapperWrapper;

namespace DapperWrapper
{
    public class SourceContext : IDbContext
    {
        public static string _systemDataConnectionString;

        public static string SystemDataConnectionString
        {
            get
            {
                string str = ConfigurationManager.ConnectionStrings["DefaultConnection"].ToString();
                return str;
                ////if (AccountContext._answer.Server == null) return string.Empty;
                ////return _systemDataConnectionString = string.Format(
                ////    @"data source={0};initial catalog={1};user id={2};password={3}",
                ////   string.Format("{0};pooling=true;min pool size=1;max pool size=1;Connection Timeout=0", AccountContext._answer.Server), ServerConfig.Accname, AccountContext._answer.User, AccountContext._answer.Pwd);
                //return "data source=DESKTOP-1LTQ14H\\SQLSERVER;initial catalog=CFV4;user id=sa;password=718918;pooling=true;min pool size=1;max pool size=1;Connection Timeout=0";
               // return "data source=192.168.10.164,3669;initial catalog=CFV4;user id=wxtest;password=wxtest;pooling=true;min pool size=1;max pool size=1;Connection Timeout=0";
            }
        }

        public IDbConnection GetConnection()
        {
            DbConnection connection = new SqlConnection(SystemDataConnectionString);
            return connection;
        }

        public short mizhch { get; set; }

        public string mikvname
        {
            get { return "DefaultSource"; }
        }

        public string ContextName => throw new System.NotImplementedException();
    }
}